package com.ruoyi.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.result.Result;
import com.ruoyi.entity.VO.AccountInfo;
import com.ruoyi.service.IT03Service;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.domain.T03;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 客户管理Controller
 *
 * @author ruoyi
 * @date 2024-07-23
 */
@RestController
@Slf4j
@RequestMapping("/t03/t03")
public class T03Controller extends BaseController
{
    @Autowired
    private IT03Service t03Service;

    @PreAuthorize("@ss.hasPermi('t03:t03:list')")
    @GetMapping("/list")
    @ApiOperation("客户列表")
    public TableDataInfo list(T03 t03)
    {
        startPage();
        List<T03> list = t03Service.selectT03List(t03);
        return getDataTable(list);
    }
    /**
     * 导出客户管理列表
     */
    @PreAuthorize("@ss.hasPermi('t03:t03:export')")
    @Log(title = "客户管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, T03 t03)
    {
        List<T03> list = t03Service.selectT03List(t03);
        ExcelUtil<T03> util = new ExcelUtil<T03>(T03.class);
        util.exportExcel(response, list, "客户管理数据");
    }

    /**
     * 获取客户管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('t03:t03:query')")
    @GetMapping(value = "/{f0301}")
    @ApiOperation("详细信息")
    public AjaxResult getInfo(@PathVariable("f0301") Long f0301)
    {
        return success(t03Service.selectT03ByF0301(f0301));
    }

    /**
     * 新增客户管理
     */
    @Log(title = "客户管理", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增客户")
    public AjaxResult add( @RequestBody T03 t03)
    {
        return toAjax(t03Service.insertT03(t03));
    }

    /**
     * 修改客户管理
     */

    @Log(title = "客户管理", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改内容")
    public AjaxResult edit(@RequestBody T03 t03)
    {
        return toAjax(t03Service.updateT03(t03));
    }

    /**
     * 删除客户管理
     */

    @Log(title = "客户管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{f0301s}")
    @ApiOperation("删除客户")
    public AjaxResult remove(@PathVariable Long[] f0301s)
    {
        return toAjax(t03Service.deleteT03ByF0301s(f0301s));
    }
    /*
    * 获取名字
     */
    @ApiOperation("获取名字")
    @GetMapping("/getNameList")
    public List<String> getNameList()
    {
        return t03Service.selectNameList();
    }
    /*
    token赠送
     */
    @ApiOperation("赠送")
    @PutMapping("/tokenGifting")
    public Result tokenGifting(@RequestBody T03 t03){
        t03Service.tokenGifting(t03.getF0301(),t03.getF0310());
        return Result.success();
    }
}
